home *** CD-ROM | disk | FTP | other *** search
Wrap
Visual Basic class definition | 1999-08-29 | 2.5 KB | 106 lines
VERSION 1.0 CLASS BEGIN MultiUse = -1 'True END Attribute VB_Name = "EZListBox" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Public Sub LstLoadList(List As ListBox, Filename As String) On Error GoTo err Dim txt As String Dim FF As Integer FF = FreeFile Open Filename For Input As #FF Do While Not EOF(FF) Line Input #FF, txt List.AddItem txt Loop Close #FF Exit Sub err: MsgBox "Error - " & err.Description, vbCritical, "Error " & err.Number End Sub Public Sub LstSaveList(List As ListBox, Filename As String) On Error GoTo err Dim FF As Integer FF = FreeFile Open Filename For Output As #FF For i = 0 To List.ListCount Print #FF, List.List(i) Next i Close #FF Exit Sub err: MsgBox "Error - " & err.Description, vbCritical, "Error " & err.Number End Sub Public Sub LstRemove(List As ListBox, Index As Integer) List.RemoveItem Index End Sub Public Sub LstAdd(List As ListBox, Text As String) List.AddItem Text End Sub Public Property Get lstCount(List As ListBox) As Integer lstCount = List.ListCount End Property 'THE CODE BELOW IS USED FOR COMBOBOXES ONLY 'THE CODING IS ALMOST IDENTICAL, SO I THOUGHT 'I'D PUT IT IN Public Sub CmbLoadList(Combo As ComboBox, Filename As String) On Error GoTo err Dim txt As String Dim FF As Integer FF = FreeFile Open Filename For Input As #FF Do While Not EOF(FF) Line Input #FF, txt Combo.AddItem txt Loop Close #FF Combo.Text = Combo.List(0) Exit Sub err: MsgBox "Error - " & err.Description, vbCritical, "Error " & err.Number End Sub Public Sub CmdSaveList(Combo As ComboBox, Filename As String) On Error GoTo err Dim FF As Integer FF = FreeFile Open Filename For Output As #FF For i = 0 To Combo.ListCount Print #FF, Combo.List(i) Next i Close #FF Exit Sub err: MsgBox "Error - " & err.Description, vbCritical, "Error " & err.Number End Sub Public Sub About() MsgBox "EZ Listbox/Combo Class" & Chr(13) & "Copyright ⌐1999 UnpreXisten" & Chr(13) & Chr(13) & "This software is FREEWARE and may only be distributed in its original form", vbInformation, "About" End Sub End Sub Public Sub CmbRemove(Combo As ComboBox, Index As Integer) Combo.RemoveItem Index End Sub Public Sub CmbAdd(Combo As ComboBox, Text As String) Combo.AddItem Text End Sub Public Property Get CmbCount(Combo As ComboBox) As Integer CmbCount = Combo.ListCount End Property